package com.atguigu.eduservice.controller;


import com.atguigu.commonutils.Response;
import com.atguigu.eduservice.entity.subject.OneSubject;
import com.atguigu.eduservice.entity.subject.TwoSubject;
import com.atguigu.eduservice.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author zhaolie
 * @since 2020-12-07
 */
@RestController
@RequestMapping("/eduservice/subject")
@Api(description = "课程分类")
public class EduSubjectController {

    @Resource
    private EduSubjectService subjectService;

    // 添加课程分类
    @PostMapping
    @ApiOperation("添加课程分类")
    private Response addSubject(MultipartFile file) {
        // 处理上传文件
        subjectService.saveSubject(file, subjectService);
        return Response.SUCCESS();
    }

    // 课程分类列表
    @GetMapping
    @ApiOperation("课程分类列表")
    private Response listSubject() {
        List<OneSubject> list = subjectService.listSubject();
        return Response.SUCCESS().data("rows", list);
    }
}

